package com.keyroy.game.puzzle_rpg.models.animations;

import com.keyroy.game.puzzle_rpg.models.puzzle.Tile;

public class SignTileAnimation extends Animation {
	private Tile tile;
	private long time;
	private int duration;

	public SignTileAnimation(Tile tile, int duration) {
		this.tile = tile;
		this.duration = duration;
	}

	@Override
	public void execute() {
		if (time == 0) {
			time = System.currentTimeMillis() + duration;
		}

		float current = (float) (time - System.currentTimeMillis()) / (float) duration;
		if (current < 0) {
			current = 0;
		}
		tile.alpha = (int) (255 * (float) current);
	}

	@Override
	public boolean needExecute() {
		return time == 0 || time > System.currentTimeMillis();
	}

}
